home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / Snippets / Development Tools & Languages / AEGestalt / UAEClientCommand.cp < prev    next >
Encoding:
Text File  |  1995-02-05  |  2.4 KB  |  92 lines  |  [TEXT/MPS ]

  1. //    UAEClientCommand.cp
  2. //     Copyright © 1991-92 by Apple Computer, Inc. All rights reserved.
  3. //    Kent Sandvik DTS
  4. //    This file contains all the TAEClientCommand member functions, i.e.
  5. //    for creating an Apple event which will query a server over the network.
  6. //
  7. //    <1>        khs        1.0        First final version
  8.  
  9.  
  10. #ifndef __UAECLIENTCOMMAND__
  11. #include "UAEClientCommand.h"
  12. #endif
  13.  
  14.  
  15. //    Empty constructor - for avoiding ptabs in global data space
  16.  
  17. #undef Inherited
  18. #define Inherited TClientCommand
  19.  
  20. #pragma segment ARes
  21. DefineClass(TAEClientCommand, TClientCommand);
  22.  
  23. TAEClientCommand::TAEClientCommand()
  24. {
  25. }
  26.  
  27.  
  28. //     Put together the client AppleEvent, which will call the server asking for
  29. //    Gestalt information
  30. #pragma segment ASelCommand
  31. void TAEClientCommand::IAEClientCommand(CommandNumber theNum,
  32.                                                TAEDocument* theDocument,
  33.                                                AEEventID theID)
  34. {
  35.     AEAddressDesc theAddress;
  36.     FailInfo fi;
  37.  
  38.     // save document wherefrom command is issued
  39.     fDocument = theDocument;
  40.  
  41.     this->IClientCommand(theNum, theDocument, kCantUndo, kDoesNotCauseChange, NULL);
  42.     
  43.     Try(fi)
  44.     {
  45.         // setup fMessage to contain the data for our Gestalt GetData AppleEvent
  46.         theDocument->GetAEGestaltAddress(theAddress);
  47.  
  48.         TAppleEvent * aMessage = new TAppleEvent;// create AE object
  49.         aMessage->IAppleEvent(kMacAppClass, theID, theAddress, kAEQueueReply);
  50.         fMessage = aMessage;
  51.  
  52.         fi.Success();
  53.     }
  54.     else
  55.     {
  56.         this->Free();
  57.         fi.ReSignal();
  58.     }
  59. }
  60.  
  61.  
  62. //    Process replies that gets back to the client side from the AE server
  63. #pragma segment ADoCommand
  64. void TAEClientCommand::ProcessReply(TAppleEvent* theReply)
  65. {
  66.     CStr255 theResponse;
  67.     long actualSize;
  68.     DescType actualCode;
  69.     struct Configuration tempConfig;
  70.  
  71.     // handle Inherited processing and check for AE errors    
  72.     Inherited::ProcessReply(theReply);
  73.     //FailOSErr(theReply->ReadShort('errn'));
  74.  
  75.     // if OK, continue processing the reply - store it in the document
  76.     theReply->ReadParameterPtr(kAEConfig, typeConfig, actualCode, (Ptr) & tempConfig, sizeof(Configuration), actualSize);
  77.  
  78.     // Now move the tempConfig to the fDocument itself.
  79.     fDocument->ReadConfiguration(&tempConfig);
  80.  
  81.     // FUTURE: Make a TProcessGestaltCommand which will process the information
  82.     // and store it in the TInformationView
  83.     // TProcessGestaltCommand aCommand = new TProcessGestaltCommand(this,tempConfig);
  84.     // and so on...
  85.  
  86.     // Process the reply to a more suitable format, this is done from the
  87.     // document itself for the view class
  88.     fDocument->ProcessAEInformation();
  89. }
  90.  
  91.  
  92.